<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@ include file="static_res.jsp"%>
<script>
	$(function() {
		Materialize.toast('你好，探险家 ！', 3000);
		
		$('#username').blur(function(){
			
			if ($('#username').val() == "") 
			{
				Materialize.toast('账号不能为空 ！', 3000);
				return false;
			}
			var param = "username=" + $("#username").val();
			$.ajax({
				type : "POST",
				url : "<%=path %>/user/nameRepeat.do",
				data : param,
				dateType : "text",
				success : function(result) {
					if ("1" == result)
					{
						//Materialize.toast('账号已存在，请重新输入 ！', 3000);
						$("#username").val("");
					}
					
				}
			});
		});
		
		$('#pwd').blur(function(){
			if ($('#pwd').val() == "") 
			{
				Materialize.toast('密码不能为空 ！', 3000);
				return false;
			}
		});
		
		$('#pwd1').blur(function(){
			if ($('#pwd1').val() == "") 
			{
				Materialize.toast('确认密码不能为空 ！', 3000);
				return false;
			}
			if ($('#pwd1').val()!=$('#pwd').val())
			{
				Materialize.toast('两次密码不一致，请重新输入 ！', 3000);
				$("#pwd").val("");
				$("#pwd1").val("");
				return false;
			}
		});

	});
</script>
</head>
<body>
	<div class="container">

		<div class="section"></div>
		<div class="section"></div>
		<div class="section"></div>
		<div class="section"></div>
		<div class="row">
			<form action="<%=path%>/user/register">
				<div class="col s4 offset-s4">
					<div class="card hoverable">
						<div class="card-content black-text">
							<span class="card-title">欢迎加入探险家</span>
							<div class="row"></div>
							<div class="input-field">
								<input id="username" name="username" type="text"> <label
									for="username">账号</label>
							</div>

							<div class="input-field">
								<input id="pwd" name="pwd" type="password"> <label
									for="pwd">密码</label>
							</div>

							<div class="input-field">
								<input id="pwd1" name="pwd1" type="password"> <label
									for="pwd1">再次输入密码</label>
							</div>
						</div>
						<div class="card-action center-align">
							<button class="btn waves-effect waves-light" type="submit">提交</button>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
</body>
</html>